package cd.zhixuan.utils.sample;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import cd.zhixuan.utils.ui.ISeekBar;

/**
 * @author HuZhiChao
 * Create Time: 2022.02.11
 **/
public class SampleSeekBar extends ISeekBar {
    public SampleSeekBar(Context context) {
        this(context,null);
    }

    public SampleSeekBar(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public SampleSeekBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setupProgressBackgroundView(@NonNull ImageView view, @NonNull androidx.constraintlayout.widget.Constraints.LayoutParams lp, @NonNull androidx.constraintlayout.widget.ConstraintSet set) {
        view.setBackgroundColor(Color.WHITE);
        if (HORIZONTAL) {
            set.constrainPercentHeight(view.getId(), 0.5f);
        } else {
            set.constrainPercentWidth(view.getId(), 0.5f);
        }
    }

    @Override
    public void setupProgressView(@NonNull ImageView view, @NonNull androidx.constraintlayout.widget.Constraints.LayoutParams lp, @NonNull androidx.constraintlayout.widget.ConstraintSet set) {
        view.setBackgroundColor(Color.BLUE);
        if (HORIZONTAL) {
            set.constrainPercentHeight(view.getId(), 0.3f);
        } else {
            set.constrainPercentWidth(view.getId(), 0.3f);
        }
    }

    @Override
    public void setupIndicateView(@NonNull ImageView view, @NonNull androidx.constraintlayout.widget.Constraints.LayoutParams lp, @NonNull androidx.constraintlayout.widget.ConstraintSet set) {
//        set.setDimensionRatio(view.getId(),"1");
        set.constrainPercentWidth(view.getId(), 0.1f);
        set.constrainPercentHeight(view.getId(),0.1f);
        view.setBackgroundColor(Color.RED);

    }
}
